﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Diagnostics;
using System.ComponentModel;
using System.Windows.Forms;
using Microsoft.Office.Interop.Word;
using System.Threading;

namespace TestFYP
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : System.Windows.Window
    {

        private Microsoft.Office.Interop.Word.Application app;
        private Document doc;
        private Object Filename;
        private BackgroundWorker bw;
        bool docopened = false;
        int intFound = 0;
        DocumentPrep docprep;

        public Window1()
        {
            InitializeComponent();
            docprep = new DocumentPrep(this);
        }

        private void btnMinimize_Click(object sender, System.Windows.RoutedEventArgs e)
        {
        	// TODO: Add event handler implementation here.
            this.WindowState = WindowState.Minimized;
        }

        private void btnClose_Click(object sender, System.Windows.RoutedEventArgs e)
        {
        	// TODO: Add event handler implementation here.

            docprep.closeDoc();
           
        }

        private void Rectangle_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
        	// TODO: Add event handler implementation here.
			this.DragMove();
        }

        

        private void btnFile_Click(object sender, System.Windows.RoutedEventArgs e)
        {
        	// TODO: Add event handler implementation here.
            OpenFileDialog ofd = new OpenFileDialog();
            if(ofd.ShowDialog().ToString().Equals("OK"))    
                txtFile.Text = ofd.FileName;
        }

        private void btnOpen_Click(object sender, System.Windows.RoutedEventArgs e)
        {
        	// TODO: Add event handler implementation here.

            Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
            docprep.loadDoc(txtFile.Text);

        }

        private void txtFile_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
        {
        	// TODO: Add event handler implementation here.
            if (txtFile.Text == String.Empty)
                btnOpen.IsEnabled = false;
            else
                btnOpen.IsEnabled = true;
				
        }

        private void btnExit_Click(object sender, RoutedEventArgs e)
        { 
            docprep.closeDoc();
            this.Close();            
        }
       
		
    }   


}
